#include <iostream>
#include <string>

//电源插座，三插头到两插头的适配
class ThreeOutlet {
public:
    void ThreeOutletCharge() {
        std::cout << "开始三插头充电" << std::endl;
    }
};

class AbstractTwoOutlet {
public:
    virtual void TwoOutletCharge() = 0;
};

class TwoOutlet : public AbstractTwoOutlet { 
public:
    void TwoOutletCharge() {
        std::cout << "开始两插头充电" << std::endl;
    }
};

//针对对象进行适配
class TwoOutletAdapter : public AbstractTwoOutlet { 
public:
    TwoOutletAdapter(ThreeOutlet* threeOutlet) {
        this->threeOutlet = threeOutlet;
    }
    //转换函数
    void Convertor() {
        std::cout << "三插头转换为两插头" << std::endl;
    }

    void TwoOutletCharge() {
        Convertor();
        threeOutlet->ThreeOutletCharge();
    }
private:
    ThreeOutlet* threeOutlet;
};

//针对类进行适配
class OutletAdapter : public AbstractTwoOutlet, public ThreeOutlet { 
public:
    void convertor() { 
        std::cout << "三插头转换为两插头" << std::endl;
    }
    void TwoOutletCharge() {
        convertor();
        ThreeOutletCharge();
    }
};

int main(int argc, char const *argv[]) {
    ThreeOutlet* threeOutlet = new ThreeOutlet();
    threeOutlet->ThreeOutletCharge();
    AbstractTwoOutlet* twoOutlet = new TwoOutletAdapter(threeOutlet);
    twoOutlet->TwoOutletCharge();

    OutletAdapter* outletAdapter = new OutletAdapter();
    outletAdapter->TwoOutletCharge();
    return 0;
}